home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / gencsrc.zip / BITFIELD.C < prev    next >
C/C++ Source or Header  |  1987-11-21  |  417b  |  18 lines

  1.                                          /* Chapter 11 - Program 7 */
  2. main()
  3. {
  4. union {
  5.    int index;
  6.    struct {
  7.       unsigned int x : 1;
  8.       unsigned int y : 2;
  9.       unsigned int z : 2;
  10.    } bits;
  11. } number;
  12.  
  13.    for (number.index = 0;number.index < 20;number.index++) {
  14.       printf("index = %3d, bits = %3d%3d%3d\n",number.index,
  15.               number.bits.z,number.bits.y,number.bits.x);
  16.    }
  17. }
  18.